Add skern init instruction-snippet writer#87
Merged
Conversation
`skern init` can now write a skern usage snippet into agent instruction files (AGENTS.md, CLAUDE.md, .claude/CLAUDE.md). The snippet teaches the agent to use skern for ALL skill-related tasks instead of reading platform-native skill directories. Off by default — opt in with `--instructions` or accept the interactive prompt on a TTY. Implementation: - internal/cli/instructions/ — new package. Two embedded markdown fragments (base.md always included, tool_forming.md opt-in), assembled by Render(). The writer wraps output in <!-- skern:instructions:start --> / <!-- skern:instructions:end --> markers so re-running updates the block in place rather than appending duplicates. Auto-discovery probes AGENTS.md, CLAUDE.md, .claude/CLAUDE.md in cwd; user-level files require explicit --target. - internal/cli/init.go — new flags: --instructions, --tool-forming-loop, --target (repeatable), --print-instructions. Interactive TTY prompts for both choices when flags don't fully resolve them; default No for both. Prompts go to stderr so they don't collide with --print-instructions on stdout. JSON mode never prompts. - internal/output/types_skill.go — InitResult grows an optional `instructions` field reporting tool_forming choice, candidate targets, and per-file write actions (created/updated/unchanged/ appended/printed). - scripts/smoke_test.sh — three new tests cover the discover-and-write, default-off, and print-only flows. - docs/reference/commands.md, CHANGELOG.md updated. Tool-forming-loop is intentionally opt-in per user preference: agents that already know to create skills as needed don't need the explicit search-before-create directive in their context budget. Verified locally: go test ./... pass, golangci-lint clean, 65/65 smoke tests pass on Windows. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
devrimcavusoglu
added a commit
that referenced
this pull request
May 7, 2026
Move the [Unreleased] block to v0.3.0 dated 2026-05-07, with a focused "Breaking changes" section calling out the --from-template directory requirement (#84). Cross-link the four PRs that landed since v0.2.1 (#81, #84, #86, #87) and add a Changed entry covering the docs-site refresh that ships in this branch. Bump the corresponding version refs in AGENTS.md (current release + milestone snapshot now covers M0–M7), INSTALL.md (SKERN_VERSION pin example), docs/guide/installation.md (matching pin example), and docs/guide/index.md (current-release callout). Docs build verified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
3 tasks
devrimcavusoglu
added a commit
that referenced
this pull request
May 7, 2026
* Refresh docs site for v0.2.1 (eight platforms, init instructions, skill versioning) Bring the VitePress site up to date with the v0.2.0 / v0.2.1 surface that has landed since the last docs refresh: - Eight platform adapters wherever 3 were listed (index, guide, concepts diagram, reference flag enums, platforms index/comparison) and a dedicated page for each new adapter (cursor, gemini-cli, github-copilot, windsurf, continue). - `skern init --instructions` / `--tool-forming-loop` / `--target` / `--print-instructions` documented in the quick-start, agent-setup, and command reference. Agent-setup now leads with `init --instructions` instead of the manual `echo … >> AGENTS.md` recipe. - Reference reorganized: registry vs. platform command groups, full pages for `skill import`, `skill version`, `skill diff`, capacity reporting on install/uninstall, `--enforce-budget`, `--with-platforms`, batch install/uninstall. - Validation page split into errors / warnings / hints with the trigger-prefix and recommended-section hints. - Skill format page corrected to the nested `metadata.author` / `metadata.version` / `metadata.modified-by` schema and includes the import workflow. - Installation page covers macOS, Linux, and Windows (PowerShell) one-liners plus version pinning, custom install dir, source build, manual install, uninstall. - Contributing/development reflects the declarative platform spec, updated Make targets, and the `cli/instructions/` package. - Sidebar adds the new platform pages and a Writing Skills entry under Guide. Build verified with `npm run docs:build` (clean). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> * Cut v0.3.0: stamp CHANGELOG, bump version refs Move the [Unreleased] block to v0.3.0 dated 2026-05-07, with a focused "Breaking changes" section calling out the --from-template directory requirement (#84). Cross-link the four PRs that landed since v0.2.1 (#81, #84, #86, #87) and add a Changed entry covering the docs-site refresh that ships in this branch. Bump the corresponding version refs in AGENTS.md (current release + milestone snapshot now covers M0–M7), INSTALL.md (SKERN_VERSION pin example), docs/guide/installation.md (matching pin example), and docs/guide/index.md (current-release callout). Docs build verified. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
skern initcan now write a skern usage snippet into agent instruction files (AGENTS.md,CLAUDE.md,.claude/CLAUDE.md) so agents use skern for ALL skill-related tasks instead of reading platform-native skill directories. Off by default — opt in with--instructionsor accept the interactive prompt on a TTY.This is the foundation for the planned shift from install/uninstall as the primary verb to a skern-as-source-of-truth model: instead of copying skill files to each platform's
.claude/skills/,.cursor/skills/, etc., the agent is instructed to callskern skill <verb>directly.What gets written
The base snippet (always included when opted in):
Plus the optional
--tool-forming-loopsection (off by default — agents that already create skills as needed shouldn't pay the context budget for an explicit directive):Wrapped in
<!-- skern:instructions:start -->/<!-- skern:instructions:end -->markers so re-running updates the block in place.Flags
--instructions--tool-forming-loop--target <path>--print-instructionsOn a TTY without
--jsonor instruction flags,skern initprompts for both choices (default No). Non-interactive runs honor flags only.Implementation
internal/cli/instructions/— new package.base.md+tool_forming.mdare//go:embeded and assembled byRender(toolForming bool).Write()handles append, in-place update, and no-op cases via marker pattern.internal/cli/init.go— flag wiring, prompt resolution. Prompts go to stderr so they don't collide with--print-instructionson stdout. Cross-platform TTY detection viaos.ModeCharDevice(no third-party deps).internal/output/types_skill.go—InitResult.Instructions(optional, omitted when not opted in) reports tool-forming choice, candidate targets, and per-file write actions.scripts/smoke_test.sh— three new tests covering discover-and-write, default-off, and print-only.Verified locally (Windows)
go test ./...— all packages passgolangci-lint run ./...— 0 issuesbash scripts/smoke_test.sh ./skern— 65/65 (was 57)Test plan
lintjob cleanskern initbehavior unchanged (no flags → just creates.skern/)omitempty)Related